package com.huabo.contract.service.impl;

import com.hbfk.util.PageInfo;
import com.huabo.contract.config.DateBaseConfig;
import com.huabo.contract.oracle.entity.TblLegalFrozenaccount;
import com.huabo.contract.oracle.mapper.TblLegalFrozenaccountMapper;
import com.huabo.contract.service.TblLegalFrozenaccountService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Service
public class TblLegalFrozenaccountServiceImpl implements TblLegalFrozenaccountService {

    @Resource
    private TblLegalFrozenaccountMapper tblLegalFrozenaccountMapper;

    @Override
    public void findListByPageInfo(PageInfo<TblLegalFrozenaccount> pageInfo, TblLegalFrozenaccount frozenAccount,Integer disputeid) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            Map<String, Object> resultMap = new HashMap<String, Object>(0);
            pageInfo.setTlist(tblLegalFrozenaccountMapper.findListByPageInfo(pageInfo, frozenAccount, disputeid));
            pageInfo.setTotalRecord(tblLegalFrozenaccountMapper.findListByPageInfoCount(frozenAccount, disputeid));
            resultMap.put("code", "1");
            resultMap.put("msg", "访问接口成功");
            resultMap.put("date", pageInfo);
        } else {
            Map<String, Object> resultMap = new HashMap<String, Object>(0);
            pageInfo.setTlist(tblLegalFrozenaccountMapper.findListByPageInfo(pageInfo, frozenAccount, disputeid));
            pageInfo.setTotalRecord(tblLegalFrozenaccountMapper.findListByPageInfoCount(frozenAccount, disputeid));
            resultMap.put("code", "1");
            resultMap.put("msg", "访问接口成功");
            resultMap.put("date", pageInfo);
        }
    }

    @Override
    public TblLegalFrozenaccount findById(Integer inforId) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            return tblLegalFrozenaccountMapper.findByInforid(inforId);
        } else {
            return tblLegalFrozenaccountMapper.findByInforid(inforId);
        }
    }

    @Override
    public void saveFrozenAccount(TblLegalFrozenaccount frozen) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            tblLegalFrozenaccountMapper.saveFrozenAccount(frozen);
        } else {
            tblLegalFrozenaccountMapper.saveFrozenAccount(frozen);
        }
    }

    @Override
    public void updateModifyFrozenAccount(TblLegalFrozenaccount oldFrozen) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            tblLegalFrozenaccountMapper.updateModifyFrozenAccount(oldFrozen);
        } else {
            tblLegalFrozenaccountMapper.updateModifyFrozenAccount(oldFrozen);
        }
    }

    @Override
    public void removeFrozenAccount(Integer inforId) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            this.tblLegalFrozenaccountMapper.removeFrozenAccount(inforId);
        } else {
            this.tblLegalFrozenaccountMapper.removeFrozenAccount(inforId);
        }
    }

    @Override
    public TblLegalFrozenaccount findInforid(Integer inforId) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            return tblLegalFrozenaccountMapper.findInforid(inforId);
        } else {
            return tblLegalFrozenaccountMapper.findInforid(inforId);
        }
    }
}
